//
// Created by xili on 2024/8/31 13:52.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    int minStoneSum(vector<int> &piles, int k) {
        priority_queue<int> pq(piles.begin(), piles.end());
        while (k--) {
            int t = pq.top();
            pq.pop();
            pq.push(t - t / 2);
        }
        int ans = 0;
        while (!pq.empty()) {
            ans += pq.top();
            pq.pop();
        }
        return ans;
    }
};